import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class KeyPressPage extends StatefulWidget {
  const KeyPressPage({super.key});

  @override
  State<KeyPressPage> createState() => _KeyPressPageState();
}

class _KeyPressPageState extends State<KeyPressPage> {
  // BasicMessageChannel<Object?> channel = SystemChannels.keyEvent;
  String result = "";

  // @override
  // void initState() {
  //   channel.setMessageHandler((message) => _handleMessage(message));
  //   super.initState();
  // }

  // @override
  // void dispose() {
  //   channel.setMessageHandler(null);
  //   super.dispose();
  // }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        const TextField(),
        Text("result=$result"),
      ],
    );
  }

  _handleMessage(Object? message) async {
    setState(() {
      result = message.toString();
    });
    return {"handled": true};
  }
}
